﻿namespace Contoso.ActiveDirectory {
    public class QueryFilters {
        public QueryFilters() {
            unchecked {
                SecurityGroupFilter = string.Format("(&(objectCategory=group)(|(groupType={0})(groupType={1})(groupType={2})(groupType={3})))",
                    ((int)GroupTypeFlags.BuiltInSecurity).ToString(), ((int)GroupTypeFlags.LocalSecurity).ToString(),
                    ((int)GroupTypeFlags.GlobalSecurity).ToString(), ((int)GroupTypeFlags.UniversalSecurity).ToString());
            }
        }

        public readonly string AccountLockedOut = string.Format("(&(objectCategory=person)(objectClass=user)(userAccountControl:{0}:=16))", LdapMatchingRules.LDAP_MATCHING_RULE_BIT_AND);
        public readonly string ActiveSyncSubscriber = string.Format("(&(objectCategory=person)(objectClass=user)(mail=*)(homeMDB=*)(msExchMobileMailboxFlags=1))");
        public readonly string ComputerAccounts = "(objectCategory=computer)";
        public readonly string ConflictFlagObjects = string.Format("CN=*{0}*", ADDataAccess.ConflictFlag);
        public readonly string Contacts = "(&(objectCategory=person)(objectClass=contact))";
        public readonly string DeletedObjects = string.Format("CN=*{0}*", ADDataAccess.TombstoneFlag);
        public readonly string DisabledAccounts = string.Format("(&(objectCategory=person)(objectClass=user)(userAccountControl:{0}:=2))", LdapMatchingRules.LDAP_MATCHING_RULE_BIT_AND);
        public readonly string DomainControllers = "(&(objectCategory=computer)(primaryGroupId=516))";
        public readonly string ExchangeMailboxHolder = "(&(homeMDB=*)(mailNickname=*))";
        public readonly string GroupFilter = "(objectCategory=group)";
        public readonly string GlobalCatalogServers = string.Format("(&(objectCategory=nTDSDSA)(options:{0}:=1))", LdapMatchingRules.LDAP_MATCHING_RULE_BIT_AND);
        public readonly string MustChangePassword = "(&(objectCategory=person)(objectClass=user)(pwdLastSet=0))";
        public readonly string OrganizationUnit = "(objectCategory=organizationalUnit)";
        public readonly string PasswordNeverExpires = string.Format("(&(objectCategory=person)(objectClass=user)(userAccountControl:{0}:=65536))", LdapMatchingRules.LDAP_MATCHING_RULE_BIT_AND);
        public readonly string SecurityGroupFilter;
        public readonly string SmartCardRequiredAccounts = string.Format("(&(objectCategory=person)(objectClass=user)(userAccountControl:{0}:=262144))", LdapMatchingRules.LDAP_MATCHING_RULE_BIT_AND);
        public readonly string UserAccounts = "(&(objectCategory=person)(objectClass=user))";
        public readonly string UserGroupObjects = "(|(&(objectCategory=person)(objectClass=user))(objectCategory=group))";
        public readonly string UserGroupComputerObjects = "(|(&(objectCategory=person)(objectClass=user))(objectCategory=group)(objectCategory=computer))";
    }
}
